//    entity language compiler Copyright (C) 2011 Vincent Belliard

//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation version 3 of the License.

//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.

//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.

class T_expression_local ;
class T_expression_identifier ;
class T_expression_loop ;
class T_object_class_method ;

class T_scope
	{
public:
	T_scope *previous_scope ;
	T_scope(T_scope *new_previous_scope) { previous_scope = new_previous_scope ; }
	virtual ~T_scope() {}
	virtual int is_block(void) const { return FALSE ; }
	virtual int is_loop(void) const { return FALSE ; }
	virtual int is_compute(void) const { return FALSE ; }
	virtual int is_method(void) const { return FALSE ; }
	virtual int is_constructor(void) const { return FALSE ; }
	virtual int search_identifier(T_expression_identifier *expression, const T_string &name) = 0 ;
	} ;

class T_scope_local : public LINK<T_scope_local>
	{
public:
	T_expression_local *local ;
	T_scope_local(T_expression_local *new_local) { local = new_local ; }
	} ;

class T_block_scope : public T_scope
	{
public:
	LIST<T_scope_local> locals ;
	T_block_scope(T_scope *new_previous_scope) : T_scope(new_previous_scope) {}
	virtual int is_block(void) const { return TRUE ; }
	virtual int search_identifier(T_expression_identifier *expression, const T_string &name) ;
	} ;

class T_loop_scope : public T_scope
	{
public:
	T_expression_loop *loop ;
	T_loop_scope(T_scope *new_previous_scope, T_expression_loop *new_loop) : T_scope(new_previous_scope) { loop = new_loop ; }
	virtual int is_loop(void) const { return TRUE ; }
	virtual int search_identifier(T_expression_identifier *expression, const T_string &name) { return FALSE ; }
	} ;

class T_compute_scope : public T_scope
	{
public:
	T_expression_compute *compute ;
	T_compute_scope(T_scope *new_previous_scope, T_expression_compute *new_compute) : T_scope(new_previous_scope) { compute = new_compute ; }
	virtual int is_compute(void) const { return TRUE ; }
	virtual int search_identifier(T_expression_identifier *expression, const T_string &name) { return FALSE ; }
	} ;

class T_object_class_method_scope : public T_scope
	{
public:
	T_object_class_method *method ;
	T_object_class_method_scope(T_scope *new_previous_scope, T_object_class_method *new_method) : T_scope(new_previous_scope) { method = new_method ; }
	virtual int is_method(void) const { return TRUE ; }
	virtual int search_identifier(T_expression_identifier *expression, const T_string &name) ;
	} ;

class T_object_class_constructor_scope : public T_scope
	{
public:
	T_constructor *constructor ;
	T_object_class_constructor_scope(T_scope *new_previous_scope, T_constructor *new_constructor) : T_scope(new_previous_scope) { constructor = new_constructor ; }
	virtual int is_constructor(void) const { return TRUE ; }
	virtual int search_identifier(T_expression_identifier *expression, const T_string &name) ;
	} ;
